package com.ruoyi.service.impl;

import com.ruoyi.domain.T03;
import com.ruoyi.domain.T06;
import com.ruoyi.domain.T10T;
import com.ruoyi.entity.DTO.T10DTO;
import com.ruoyi.entity.VO.T10TVO;
import com.ruoyi.mapper.T03Mapper;
import com.ruoyi.mapper.T10TMapper;
import com.ruoyi.service.IT06Service;
import com.ruoyi.service.IT10TService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class T10TServiceImpl implements IT10TService {
    @Autowired
    private T10TMapper t10Mapper;
    @Autowired
    private T03Mapper t03Mapper;
    @Autowired
    private IT06Service t06Service;

    @Override
    public List<T10TVO> selectT10List(T10DTO t10) {
        List<T10T> t10TS = t10Mapper.selectT10List(t10);
        List<Long> F0301s = new ArrayList<>();
        List<Long> F0601s= new ArrayList<>();
        if(!t10TS.isEmpty()){
            for (T10T t10T : t10TS) {
                F0301s.add(t10T.getF0301());
                F0601s.add(t10T.getF0601());
            }
        }
        List<T03> T03s=new ArrayList<>();
        List<T06> t06s=new ArrayList<>();
        List<T10TVO> t10VOs=new ArrayList<>();
        if(!F0301s.isEmpty()){
            T03s=t03Mapper.selectT03ListByF0301s(F0301s);
        }
        if(!F0601s.isEmpty()){
            t06s=t06Service.selectT06ListByF0601s(F0601s);
        }
        if(!t10TS.isEmpty()){
            for (int i=0;i<t10TS.size();i++) {
                T10TVO t10TVO=new T10TVO();
                BeanUtils.copyProperties(t10TS.get(i),t10TVO);
                t10TVO.setF0302(T03s.get(i).getF0302());
                t10TVO.setGetToken((long) (t10TS.get(i).getF1002()/T03s.get(i).getF0306()));
                t10TVO.setF0602(t06s.get(i).getF0602());
                t10VOs.add(t10TVO);
            }
        }
        return t10VOs;
    }
}
